package com.example.security.my.controller;

import com.example.security.my.annotation.AnonymousAccess;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * MyController
 *
 * @author zhouxianfeng
 * @date 2021-4-29
 */
@RestController
@RequestMapping("/my")
public class MyController {

    @AnonymousAccess
    @GetMapping("/test")
    public String test() {
        return "test1";
    }

    @PreAuthorize("anonymous")
    @GetMapping("/test2")
    public String test2() {
        return "test2";
    }
}
